package cn.codewen.shop.service.impl;

import cn.codewen.shop.dao.CategoryDao;
import cn.codewen.shop.dao.impl.CategoryDaoImpl;
import cn.codewen.shop.pojo.Category;
import cn.codewen.shop.service.CategoryService;

import java.util.List;

public class CategoryServiceImpl implements CategoryService {
    @Override
    public List<Category> findAll() {
        //1. 实例化对象categoryDao
        CategoryDao categoryDao = new CategoryDaoImpl();
        List<Category> categories = categoryDao.findAll();
        return categories;
    }

    @Override
    public void insert(Category category) {
        //1. 实例化对象categoryDao
        CategoryDao categoryDao = new CategoryDaoImpl();
        categoryDao.insert(category);
    }

    @Override
    public void save(Category category) {
        //1. 实例化对象categoryDao
        CategoryDao categoryDao = new CategoryDaoImpl();
        categoryDao.save(category);
    }

    @Override
    public Category getCateById(int id) {
        //1. 实例化对象categoryDao
        CategoryDao categoryDao = new CategoryDaoImpl();
        return categoryDao.getCateById(id);
    }

    @Override
    public void delete(int id) {
        //1. 实例化对象categoryDao
        CategoryDao categoryDao = new CategoryDaoImpl();
        categoryDao.delete(id);
    }
}
